// 铅笔基类
import {Sprite} from "../base/sprite.js";
import { DataStore } from "../base/dataStore.js";

export class Pencil extends Sprite{
  constructor(image,top){
    super(image, 0, 0,
      image.width, image.height,
      // 刚好在右侧看不到的位置
      DataStore.getInstance().canvas.width, 0,
      image.width, image.height
    ); // 调用父类的constructor(ctx,image,0,0,image.width, image.height,0, 0,image.width, image.height)
    this.top  = top;
    this.moveSpeed = 2;
  }
  draw(){
    this.x = this.x -this.moveSpeed;
    super.draw(this.image, 0, 0,
      this.img.width, this.img.height,
      // 刚好在右侧看不到的位置
      this.x, this.y,
      this.width, this.height
    );
  }
}